package com.infonam.data.source.model;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name="category", catalog="sakila")
public class Category  {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="category_id", nullable=false,unique=true)
	private int category_id;
	@Column(name="name", length=25, nullable=false)
	private String name;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="last_update", columnDefinition="TIMESTAMP default CURRENT_TIMESTAMP on update TIMESTAMP")
	private Date last_update;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="fk.category")
	@Cascade({CascadeType.ALL})
	private List<FilmCategory> listFilmCategory = new LinkedList<FilmCategory>();
	public int getCategory_id() {
		return category_id;
	}
	public void setCategory_id(int category_id) {
		this.category_id = category_id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Date getLast_update() {
		return last_update;
	}
	public void setLast_update(Date last_update) {
		this.last_update = last_update;
	}
	public List<FilmCategory> getListFilmCategory() {
		return listFilmCategory;
	}
	public void setListFilmCategory(List<FilmCategory> listFilmCategory) {
		this.listFilmCategory = listFilmCategory;
	}

}
